package com.zzptc.zzsgz.bdsjws.fragments;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.zzptc.zzsgz.bdsjws.Adapter.ContactAdapter;
import com.zzptc.zzsgz.bdsjws.MyApplication;
import com.zzptc.zzsgz.bdsjws.R;
import com.zzptc.zzsgz.bdsjws.fragments.base.BaseFragmentbase;
import com.zzptc.zzsgz.bdsjws.vo.Contact;

import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;


public class SelectContactFragment extends BaseFragmentbase {
    @BindView(R.id.rv_select_contact)
    RecyclerView rvSelectContact;
    List<Contact> contactsList = new ArrayList<Contact>();
    ContactAdapter contactAdapter;
    @Override
    public int getXML() {
        return R.layout.select_contact_fragment;
    }

    @Override
    public void initView() {


//        List<Contact> anyList = new ArrayList<Contact>();
//        List<Contact> allList = MyApplication.getList();
//        //要获得输入框里面的是数据来进行匹配
//        if (getActivity() instanceof AddContactsActivity){
//
//        }
//
//        for (int i = 0 ; i < allList.size() ; i++){
//
//        }
//        ContactAdapter contactAdapter = new ContactAdapter(anyList);
//        rvSelectContact.setLayoutManager(new LinearLayoutManager(MyApplication.getContext()));


    }

    @Override
    public void initDate() {
        rvSelectContact.setLayoutManager(new LinearLayoutManager(MyApplication.getContext()));
        contactAdapter = new ContactAdapter(contactsList);
        rvSelectContact.setAdapter(contactAdapter);
    }

    public void getSelectContactList (List<Contact> contacts){
        contactsList.clear();
        contactsList.addAll(contacts);
        if (contactAdapter != null){
            contactAdapter.notifyDataSetChanged();
        }

    }


}
